/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.icatportal.client.mvc;

import com.extjs.gxt.ui.client.Events;
import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.event.ComponentEvent;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.mvc.AppEvent;
import com.extjs.gxt.ui.client.mvc.Controller;
import com.extjs.gxt.ui.client.mvc.View;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.mvc.Dispatcher;

import org.icatportal.client.AppEvents;

/**
 *
 * @author ll56
 */
public class PreferenceFolderView extends View {

  private ContentPanel preference;
  private ContentPanel news;

  public PreferenceFolderView(Controller controller) {
    super(controller);
  }

  @Override
  protected void handleEvent(AppEvent event) {
    switch (event.type) {
      case AppEvents.Init:
        initUI();
        break;
    }
  }
  
  @Override
  protected void initialize() {

  }

  protected void initUI() {
    preference = new ContentPanel();
    preference.setHeading("Preference!");
    preference.addListener(Events.Expand, new Listener<ComponentEvent>() {
      public void handleEvent(ComponentEvent be) {
        Dispatcher.get().dispatch(AppEvents.NavPreference);
      }
    });
    preference.addText("Here, we display user preferences." );
    news = new ContentPanel();
    news.setHeading("News!");
    news.addListener(Events.Expand, new Listener<ComponentEvent>() {
      public void handleEvent(ComponentEvent be) {
        Dispatcher.get().dispatch(AppEvents.NavNews);
      }
    });
    
    news.addText("Here, we display messages for the users." );

    ContentPanel west = (ContentPanel) Registry.get("west");
    west.add(preference);
    west.add(news);
  }
}
